<?php

namespace Modules\Edu\Http\Controllers\Front;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Modules\Edu\Entities\Video;

class VideoController extends Controller
{

    public function index()
    {
        $videos = Video::site()->latest('updated_at');
        if (\Browser::isMobile()) {
            $videos = $videos->simplePaginate(5);
        } else {
            $videos = $videos->paginate();
        }
        return view('edu::video.index', compact('videos'));
    }

    public function show(Video $video)
    {
        //学习记录
        //
        if (Auth::check()) {
            user()->make()->studys()->syncWithoutDetaching(
                [$video->id => ['site_id' => site()['id']]

                ]);

        }
        return view('edu::video.show', compact('video'));
    }


}
